/*
 * Copyright 2009-2015 by WWW.KNET.CN  All rights reserved.
 */

package cn.knet.sp.ncrm.modules.sys.producttype.service;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.knet.sp.ncrm.common.persistence.Page;
import cn.knet.sp.ncrm.common.service.CrudService;
import cn.knet.sp.ncrm.modules.sys.producttype.dao.ProductTypeDao;
import cn.knet.sp.ncrm.modules.sys.producttype.entity.ProductType;
import cn.knet.sp.ncrm.modules.sys.utils.ProductUtils;

/**
 * 产品类型crudService
 * @author zhangbin
 * @version 2015-08-24
 */
@Service
@Transactional(readOnly = true)
public class ProductTypeService extends CrudService<ProductTypeDao, ProductType> {

	public ProductType get(String id) {
		return super.get(id);
	}
	
	public List<ProductType> findList(ProductType productType) {
		return super.findList(productType);
	}
	
	public Page<ProductType> findPage(Page<ProductType> page, ProductType productType) {
		return super.findPage(page, productType);
	}
	
	@Transactional(readOnly = false)
	public void save(ProductType productType) {
		super.save(productType);
		ProductUtils.clearCache(productType);
	}
	
	@Transactional(readOnly = false)
	public void delete(ProductType productType) {
		super.delete(productType);
		ProductUtils.clearCache(productType);
	}

	public int findDistinctProductType(ProductType productType) {
		return dao.findDistinctProductType(productType);
	}
	@Transactional(readOnly = false)
	public void updateStatus(String[] ids, String status) {
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("ids",ids);
		param.put("status",status);
		dao.updateStatus(param);
		ProductUtils.clearCache();
	}
}